﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
using Konst3d.Efficiency.Suite;

namespace Konst3d.Efficiency.Suite.SparsedBinary
{
    internal interface IStatisticDayStorage
    {
        void SetDayActive    (DateTime date, bool active);
        void SetDayCommentary(DateTime date, string commentary);
        void SetDayValue     (DateTime date, float value);
    }

    internal class StatisticDay: IStatisticDay
    {
        #region IMonitoringStatisticStorage Members

        public DateTime Date
        {
            get;
            private set;
        }

        public bool Active
        {
            get
            {
                return _active;
            }
            set
            {
                _storage.SetDayActive(Date, value);
                _active = value;
            }
        }

        public float Value
        {
            get
            {
                return _value;
            }
            set
            {
                _storage.SetDayValue(Date, value);
                _value = value;
            }
        }

        public string Commentary
        {
            get
            {
                return _commentary;
            }
            set
            {
                _storage.SetDayCommentary(Date, value);
                _commentary = value;
            }
        }

        #endregion // IMonitoringStatisticStorage Members

        #region Constructor

        public StatisticDay(IStatisticDayStorage storage, DateTime date, bool active, float value, string commentary)
        {
            Contract.Requires(storage != null);

            Date = date;

            _storage = storage;
            _active = active;
            _value = value;
            _commentary = commentary;
        }

        #endregion // Constructor

        #region Fields

        private IStatisticDayStorage _storage;
        private bool _active;
        private float _value;
        private string _commentary;

        #endregion // Fields
    }
}
